home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-05 / 21ripl.zip / RPLMIG21.CMD < prev   
OS/2 REXX Batch file  |  1993-03-15  |  34KB  |  931 lines

  1. /* RPLMIG21.CMD - REXX program to upgrade LAN Server to support RIPL of      */
  2. /*                OS/2 2.1.  The following upgrades are preformed:           */
  3. /*                                                                           */
  4. /*                  - Install new RIPL support files                         */
  5. /*                  - Create os221*.cnf files                                */
  6. /*                  - Create server records for os221*.cnf files in RPL.MAP  */
  7. /*                                                                           */
  8. /*    Copyright: (C) Copyright IBM Corp. 1993                                */
  9. /*                                                                           */
  10. /*    Note 1: All NLS message strings are centrally located in the           */
  11. /*            subroutine Initialize_NLS_Messages at the end of this          */
  12. /*            rexx procedure.                                                */
  13.  
  14. CRLF = '0A0D'X
  15. nulsufix = ' 1>nul 2>nul'
  16. ERROR_INFO_type = 1
  17. SYNTAX_type = 2
  18. SourcePath = 'A:\'
  19. Logfile = ''
  20.  
  21. /* initialize NLS error and informational message strings */
  22. Call Initialize_NLS_Messages ERROR_INFO_type
  23.  
  24. /* handle command line parameters */
  25. Parse Arg  clp.1 clp.2 clp.3 .
  26. Call Process_Input_Parameters clp.1, clp.2, clp.3
  27. If result <> 0 Then Call Error_Exit
  28.  
  29. /* if logfile specified, delete old log file (if it exists) & log header */
  30. If Logfile <> '' Then Do
  31.    Call Delete_File Logfile
  32.    msgdata = 'RPLMIG21 ' || message.2 || Date('U')  Time()
  33.    Call Lineout Logfile, msgdata
  34.    If result <> 0 Then Do
  35.       Say errprefix || message.3 || Logfile
  36.       exit 4
  37.    end
  38.    Call Lineout Logfile, ' '
  39. end
  40.  
  41. Call Determine_Boot_Drive
  42. If result <> 0 Then Call Error_Exit
  43.  
  44. Call Determine_RIPL_Directory
  45. If result <> 0 Then Call Error_Exit
  46.  
  47. Call Determine_LAN_Server_Version
  48. If result <> 0 Then Call Error_Exit
  49.  
  50. /* check to see if 2.1 migration needs to be run. */
  51. If File_Exist(rpldir'\RPLMIG21.$$$') = 0 Then Do
  52.  
  53.    /* create new subdirectories */
  54.    Call Create_New_Directories
  55.  
  56.    /* copy new/changed RIPL files */
  57.    Call Copy_RIPL_Files
  58.    If result <> 0 Then Call Error_Exit
  59.  
  60.    /* update server name references in new DEFALT21.FIT */
  61.    Call Update_DEFALT21_FIT
  62.    If result <> 0 Then Do
  63.       Call Display_Log_Msg errprefix || message.8, ''
  64.       Call Error_Exit
  65.    end
  66.    else Call Display_Log_Msg message.17, ''
  67.  
  68.    /* update the RPL.MAP file to add server records for 2.1 and verify */
  69.    /* field 12 of workstation record is valid */
  70.    Call Update_RPL_MAP
  71.    Call Display_Log_Msg message.15, ''
  72.  
  73.    /* create the os221*.cnf files */
  74.    Call Create_os221_cnf_files
  75.    Call Display_Log_Msg message.16, ''
  76.  
  77.    /* update master CONFIGRI.20 files */
  78.    Call Update_Master_Configri_20
  79.    Call Display_Log_Msg message.21, ''
  80.  
  81.    /* create special migration file to indicate that migration is complete */
  82.    /* migration file is marked READ-ONLY */
  83.    rplm21 = rpldir'\RPLMIG21.$$$'
  84.    Call lineout rplm21, message.15
  85.    Call lineout rplm21, message.16
  86.    Call lineout rplm21
  87.    '@attrib +r 'rplm21 '1>nul'
  88. end
  89. If Logfile <> '' Then Do
  90.    Call Lineout Logfile
  91. end
  92. exit 0
  93.  
  94.  
  95. /* start of subroutines */
  96. /* This subroutine handles the error exit cleanup. */
  97. Error_Exit:
  98.    If Logfile <> '' Then Do
  99.       Call Lineout Logfile
  100.    end
  101.    exit 4
  102.  
  103.  
  104. /* subroutine to test for existance of a file */
  105. File_Exist:
  106.    Arg testfilename
  107.    If lines(testfilename) = 1 Then rc = 1
  108.    else rc = 0
  109.    /* lines() leaves file open, must force close */
  110.    Call stream testfilename,C,'close'
  111.    return rc
  112.  
  113.  
  114.  
  115. /* subroutine to delete a file */
  116. Delete_File:
  117.    arg delfilename
  118.    If lines(delfilename) <> 0 Then Do
  119.       Call stream delfilename,C,'close'
  120.       cmdline = '@DEL 'delfilename
  121.       address CMD cmdline
  122.    end
  123.    else Call stream delfilename,C,'close'  /* must do an explicit close to prevent */
  124.                                        /* a zero length file from being created */
  125.    return 0
  126.  
  127.  
  128.  
  129.  
  130. Display_Log_Msg:
  131.    Parse Arg msgstring, parm.1, parm.2, parm.3, parm.4, parm.5, parm.6
  132.    if parm.1 <> '' Then Do
  133.       /* substitution data supplied */
  134.       startpoint = 1
  135.       newmsg = ''
  136.       sdpos = pos('%', msgstring, startpoint)
  137.       Do while sdpos <> 0
  138.          j = substr(msgstring, sdpos+1, 1)
  139.          newmsg = newmsg || substr(msgstring, startpoint, sdpos-startpoint) || parm.j
  140.          startpoint = sdpos+2
  141.          sdpos = pos('%', msgstring, startpoint)
  142.       end
  143.       newmsg = newmsg || substr(msgstring, startpoint)
  144.       msgstring = newmsg
  145.    end
  146.  
  147.    If Logfile = '' Then Do
  148.       /* display message locally */
  149.       Say msgstring
  150.    end
  151.    else Do
  152.       /* log message */
  153.       Call lineout Logfile, msgstring
  154.    end
  155.    return 0
  156.  
  157.  
  158. Determine_Installed_OS2_Levels:
  159.    syslevel = '\OS2\INSTALL\SYSLEVEL.OS2'
  160.    If File_Exist(rpldir'\OS2'syslevel) = 1 Then os213 = 1
  161.    else os213 = 0
  162.  
  163.    If File_Exist(rpldir'\OS2.20'syslevel) = 1 Then os220 = 1
  164.    else os220 = 0
  165.  
  166.    If File_Exist(rpldir'\OS2.20a'syslevel) = 1 Then os220a = 1
  167.    else os220a = 0
  168.  
  169.    If File_Exist(rpldir'\OS2.21'syslevel) = 1 Then os221 = 1
  170.    else os221 = 0
  171.    return
  172.  
  173.  
  174.  
  175. /* This subroutine determines the version of LAN Server installed on  */
  176. /* the Remote IPL server. */
  177. Determine_LAN_Server_Version:
  178.    /* Read the first 60 bytes of SYSLEVEL.SRV and check the current server */
  179.    /* level.  */
  180.    filename = lanpath'\SYSLEVEL.SRV'
  181.    syslevel = ''
  182.    Do i = 1 to 60
  183.       syslevel = syslevel || charin(filename)
  184.    end
  185.    Call Charout filename
  186.  
  187.    /* get current csdlevel */
  188.    verp = pos('IP', syslevel)
  189.    csdlevel = substr(syslevel, verp, 8)
  190.    If verp <> 0 Then Do
  191.       /* recognize any level of LS 2.0 but only recognize initial release */
  192.       /* of LS 3.0 */
  193.       If substr(csdlevel, 4, 1) = '6' Then LS_version = 2
  194.       else If substr(csdlevel, 4, 1) = '7' Then Do
  195.               If substr(csdlevel, 5, 3) = '000' Then LS_version = 3
  196.               else LS_version = '3x'
  197.            end
  198.            else LS_version = ''
  199.    end
  200.    If LS_version = '' Then Do
  201.       /* not LS 2.0 or LS 3.x */
  202.       msgdata = errprefix || message.11
  203.       Call Display_Log_Msg msgdata, csdlevel
  204.       return 4
  205.    end
  206.    else If LS_version = '3x' Then Do
  207.         /* not initial LS 3.0 release */
  208.         msgdata = errprefix || message.12
  209.         Call Display_Log_Msg msgdata, csdlevel
  210.         return 4
  211.    end
  212.    return 0
  213.  
  214.  
  215.  
  216. /* create new subdirectories */
  217. Create_New_Directories:
  218.    Call Display_Log_Msg message.20, ''
  219.    /* create MACHINES\DEFALT21 tree */
  220.    '@MD 'rpldir'\MACHINES\DEFALT21'nulsufix
  221.    '@MD 'rpldir'\MACHINES\DEFALT21\IBMLAN'nulsufix
  222.  
  223.    /* create \IBMLAN\RPLUSER\DEFALT21 tree */
  224.    rupath = lanpath'\RPLUSER\DEFALT21'
  225.    '@MD 'rupath nulsufix
  226.    '@MD 'rupath'\IBMLAN'nulsufix
  227.    '@MD 'rupath'\IBMLAN\LOGS'nulsufix
  228.    '@MD 'rupath'\IBMLAN\PROFILES'nulsufix
  229.    '@MD 'rupath'\IBMLAN\ACCOUNTS'nulsufix
  230.    '@MD 'rupath'\IBMCOM'nulsufix
  231.    '@MD 'rupath'\SPOOL'nulsufix
  232.    '@MD 'rupath'\OS2'nulsufix
  233.    '@MD 'rupath'\OS2\MDOS'nulsufix
  234.    '@MD 'rupath'\OS2\MDOS\WINOS2'nulsufix
  235.    '@MD 'rupath'\OS2\SYSTEM'nulsufix
  236.    return 0
  237.  
  238.  
  239.  
  240. /* copy new/updated RIPL files to server */
  241. Copy_RIPL_Files:
  242.    /* copy requester IBMLAN.INI to DEFALT21 tree */
  243.    srcfile = rpldir'\MACHINES\DEFALT20\IBMLAN\IBMLAN.INI'
  244.    trg = rpldir'\MACHINES\DEFALT21\IBMLAN\'
  245.    Call Display_Log_Msg message.18, srcfile, trg
  246.    '@COPY 'srcfile trg nulsufix
  247.    If rc = 0 Then Do
  248.  
  249.       /* copy NET.ACC from DEFALT20 to DEFALT21 */
  250.       srcfile = lanpath'\RPLUSER\DEFALT20\IBMLAN\ACCOUNTS\NET.ACC'
  251.       trg = lanpath'\RPLUSER\DEFALT21\IBMLAN\ACCOUNTS\'
  252.       Call Display_Log_Msg message.18, srcfile, trg
  253.       '@COPY 'srcfile trg nulsufix
  254.       If rc = 0 Then Do
  255.  
  256.          /* copy AUTOEXEC.20 from DEFALT20 TO DEFALT21 */
  257.          srcfile = lanpath'\RPLUSER\DEFALT20\AUTOEXEC.20'
  258.          trg = lanpath'\RPLUSER\DEFALT21\'
  259.           Call Display_Log_Msg message.18, srcfile, trg
  260.          '@COPY 'srcfile trg nulsufix
  261.       end
  262.    end
  263.    If rc <> 0 Then Do
  264.       Call Display_Log_Msg errprefix || message.9, srcfile, trg
  265.       return 4
  266.    end
  267.  
  268.    /* if necessary, make backup copies of original .EXE files */
  269.    trg = lanpath'\NETPROG\RMM1.EX_'
  270.    if File_Exist(trg) = 0 Then Do
  271.       /* assume no backups exists, create them */
  272.       srcfile = lanpath'\NETPROG\RMM1.EXE'
  273.       Call Display_Log_Msg message.18, srcfile, trg
  274.       '@COPY 'srcfile trg nulsufix
  275.  
  276.       srcfile = lanpath'\NETPROG\GETRPL.EXE'
  277.       trg = lanpath'\NETPROG\GETRPL.EX_'
  278.       Call Display_Log_Msg message.18, srcfile, trg
  279.       '@COPY 'srcfile trg nulsufix
  280.    end
  281.  
  282.    /* rename old RPLSETD.CMD, if it exists */
  283.    If File_Exist(rpldir'\RPLSETD.CMD') = 1 Then Do
  284.       /* rename old version of RPLSETD.CMD in RPL directory */
  285.       '@RENAME 'rpldir'\RPLSETD.CMD  RPLSETD.OLD'nulsufix
  286.    end
  287.  
  288.    /* unzip common files to \IBMLAN\NETPROG */
  289.    trg = lanpath'\NETPROG\'
  290.    srcfile = SourcePath'IBMLS.ZIP'
  291.    Call Display_Log_Msg message.19, srcfile || '\*.*', trg
  292.    '@'lanpath'\INSTALL\PKUNZIP2 -o 'srcfile trg nulsufix
  293.    If rc <> 0 Then Do
  294.       Call Display_Log_Msg errprefix || message.10, srcfile, trg
  295.       return 4
  296.    end
  297.  
  298.    /* unzip version EXE files, build source path based on version */
  299.    srcfile = SourcePath'IBMLS'
  300.    If LS_version = 2 Then srcfile = srcfile || '20.ZIP'
  301.    else srcfile = srcfile ||'30.ZIP'
  302.  
  303.    /* if necessary, backup old file */
  304.    srcfile2 = lanpath'\NETPROG\RMM1.EXE'
  305.    trg2 = lanpath'\NETPROG\RMM1.EX_'
  306.    If File_Exist(trg2) = 0 Then '@COPY 'srcfile2 trg2 nulsufix
  307.  
  308.    /* if necessary, backup old file */
  309.    srcfile2 = lanpath'\NETPROG\GETRPL.EXE'
  310.    trg2 = lanpath'\NETPROG\GETRPL.EX_'
  311.    If File_Exist(trg2) = 0 Then '@COPY 'srcfile2 trg2 nulsufix
  312.  
  313.    /* RPLUPINI.EXE, if necessary, backup old file */
  314.    srcfile2 = lanpath'\NETPROG\RPLUPINI.EXE'
  315.    trg2 = lanpath'\NETPROG\RPLUPINI.EX_'
  316.    If File_Exist(trg2) = 0 Then '@COPY 'srcfile2 trg2 nulsufix
  317.  
  318.    /* unzip *.EXE files */
  319.    trg = lanpath'\NETPROG\'
  320.    Call Display_Log_Msg message.19, srcfile || '\*.EXE', trg
  321.    '@'lanpath'\INSTALL\PKUNZIP2 -o 'srcfile trg '*.EXE' nulsufix
  322.    If rc <> 0 Then Do
  323.       Call Display_Log_Msg errprefix || message.10, srcfile || '\*.EXE', trg
  324.       return 4
  325.    end
  326.  
  327.  
  328.    /* process version unique files */
  329.    If LS_version = 2 Then Do
  330.       /* LAN Server version is 2.0 */
  331.       srcfile = SourcePath'IBMLS20.ZIP'
  332.       If substr(csdlevel, 4, 4) = '6000' Then Do
  333.          /* NETWKSTA.200 and MFSD20.SYS must be replace for level 6000 */
  334.          /* NETWKSTA.200, if necessary, backup old file */
  335.          srcfile2 = lanpath'\NETPROG\NETWKSTA.200'
  336.          trg2 = lanpath'\NETPROG\NETWKSTA.20_'
  337.          If File_Exist(trg2) = 0 Then '@COPY 'srcfile2 trg2 nulsufix
  338.  
  339.          /* unzip NETWKSTA.200 */
  340.          trg = lanpath'\NETPROG\'
  341.          Call Display_Log_Msg message.19, srcfile || '\NETWKSTA.200', trg
  342.          '@'lanpath'\INSTALL\PKUNZIP2 -o 'srcfile trg 'NETWKSTA.200'nulsufix
  343.          If rc <> 0 Then Do
  344.             Call Display_Log_Msg errprefix || message.10, srcfile || '\NETWKSTA.200', trg
  345.             return 4
  346.          end
  347.          /* copy to RPL tree */
  348.          srcfile2 = rpldir'\IBMLAN\NETPROG\NETWKSTA.200'
  349.          trg2 = rpldir'\IBMLAN\NETPROG\NETWKSTA.20_'
  350.          If File_Exist(trg2) = 0 Then '@COPY 'srcfile2 trg2 nulsufix
  351.          srcfile2 = lanpath'\NETPROG\NETWKSTA.200'
  352.          trg2 = rpldir'\IBMLAN\NETPROG\'
  353.          Call Display_Log_Msg message.18, srcfile2, trg2
  354.          '@COPY 'srcfile2 trg2 nulsufix
  355.  
  356.          /* MFSD20.SYS, if necessary, backup old file */
  357.          srcfile2 = rpldir'\OS2\MFSD20.SYS'
  358.          trg2 = rpldir'\OS2\MFSD20.SY_'
  359.          If File_Exist(trg2) = 0 Then '@COPY 'srcfile2 trg2 nulsufix
  360.  
  361.          /* unzip MFSD20.SYS, note different directory from LS 3.0 */
  362.          trg = rpldir'\OS2\'
  363.          Call Display_Log_Msg message.19, srcfile || '\MFSD20.SYS', trg
  364.          '@'lanpath'\INSTALL\PKUNZIP2 -o 'srcfile trg 'MFSD20.SYS'nulsufix
  365.          If rc <> 0 Then Do
  366.             Call Display_Log_Msg errprefix || message.10, srcfile || '\MFSD20.SYS', trg
  367.             return 4
  368.          end
  369.       end
  370.    end
  371.    else Do
  372.       /* LAN Server version is 3.0 */
  373.       srcfile = SourcePath'IBMLS30.ZIP'
  374.       /* MFSD20.SYS, if necessary, backup old file */
  375.       srcfile2 = rpldir'\DOS\MFSD20.SYS'
  376.       trg2 = rpldir'\DOS\MFSD20.SY_'
  377.       If File_Exist(trg2) = 0 Then '@COPY 'srcfile2 trg2 nulsufix
  378.  
  379.       /* unzip MFSD20.SYS, note different directory from LS 2.0 */
  380.       trg = rpldir'\DOS\'
  381.       Call Display_Log_Msg message.19, srcfile || '\MFSD20.SYS', trg
  382.       '@'lanpath'\INSTALL\PKUNZIP2 -o 'srcfile trg 'MFSD20.SYS'nulsufix
  383.       If rc <> 0 Then Do
  384.          Call Display_Log_Msg errprefix || message.10, srcfile, trg
  385.          return 4
  386.       end
  387.  
  388.       /* copy new DEFALT21.FIT */
  389.       trg = rpldir'\FITS\'
  390.       Call Display_Log_Msg message.19, srcfile || '\DEFALT21.FIT', trg
  391.       '@'lanpath'\INSTALL\PKUNZIP2 -o 'srcfile trg 'DEFALT21.FIT'nulsufix
  392.       If rc <> 0 Then Do
  393.          Call Display_Log_Msg errprefix || message.10, srcfile || '\DEFALT21.FIT', trg
  394.          return 4
  395.       end
  396.  
  397.       /* PROGMAN.INI, if necessary, backup old file */
  398.       fpath = rpldir'\OS2.21\OS2\MDOS\WINOS2\'
  399.       srcfile2 = fpath || 'PROGMAN.INI'
  400.       trg2 = fpath || 'PROGMAN.IN_'
  401.       If File_Exist(trg2) = 0 Then '@COPY 'srcfile2 trg2 nulsufix
  402.       /* SYSTEM.INI, if necessary, backup old file */
  403.       srcfile2 = fpath || 'SYSTEM.INI'
  404.       trg2 = fpath || 'SYSTEM.IN_'
  405.       If File_Exist(trg2) = 0 Then '@COPY 'srcfile2 trg2 nulsufix
  406.       /* copy new WINOS2 support files */
  407.       trg = fpath
  408.       Call Display_Log_Msg message.19, srcfile || '\*.INI', trg
  409.       '@'lanpath'\INSTALL\PKUNZIP2 -o 'srcfile trg '*.INI' nulsufix
  410.       If rc <> 0 Then Do
  411.          Call Display_Log_Msg errprefix || message.10, srcfile || '\*.INI', trg
  412.          return 4
  413.       end
  414.    end
  415.  
  416.    /* copy *.INI and *.GRP files to DEFALT21 tree */
  417.    fpath = rpldir'\OS2.21\OS2\MDOS\WINOS2\'
  418.    srcfile2 = trg || '*.INI'
  419.    trg2 = lanpath'\RPLUSER\DEFALT21\OS2\MDOS\WINOS2\'
  420.    Call Display_Log_Msg message.18, srcfile2, trg2
  421.    '@XCOPY 'srcfile2 trg2 nulsufix
  422.    srcfile2 = trg || '*.GRP'
  423.    Call Display_Log_Msg message.18, srcfile2, trg2
  424.    '@XCOPY 'srcfile2 trg2 nulsufix
  425.  
  426.  
  427.  
  428.    /* TEMPORARY WORKAROUND, remove when OS/2 2.1 supports this */
  429.    /* copy 16 bit version of MAKEINI.EXE and 32 bit version of CNVTINI.EXE */
  430.    srcfile = SourcePath'OS2.ZIP'
  431.    trg = rpldir'\OS2.21\OS2\'
  432.    Call Display_Log_Msg message.19, srcfile || '\*.*', trg
  433.    '@'lanpath'\INSTALL\PKUNZIP2 -o 'srcfile trg nulsufix
  434.    If rc <> 0 Then Do
  435.       Call Display_Log_Msg errprefix || message.10, srcfile, trg
  436.       return 4
  437.    end
  438.    return 0
  439.  
  440.  
  441.  
  442. /* subroutine updates all the server name references in the DEFALT21.FIT */
  443. Update_DEFALT21_FIT:
  444.    /* get server name from first record in DEFALT20.FIT */
  445.    fit20 = rpldir'\FITS\DEFALT20.FIT'
  446.    data = linein(fit20)
  447.    Call stream fit20,C,'close'
  448.    spos = pos('\', data, 3)
  449.    If spos <> 0 Then servername = substr(data, 3, spos-3)
  450.    else Do
  451.       /* error */
  452.       Call Display_Log_Msg errprefix || message.7, ''
  453.       return 4
  454.    end
  455.  
  456.    /* read each DEFALT21.FIT record and update server name references */
  457.    fit21 = rpldir'\FITS\DEFALT21.FIT'
  458.    tmpfit21 = rpldir'\FITS\DEFALT21.TMP'
  459.    do until lines(fit21) = 0
  460.       data = linein(fit21)
  461.       ucdata = translate(data)
  462.       serverp = pos('\\SERVER\', ucdata)
  463.       if serverp <> 0 Then Do
  464.          /* replace with real server name */
  465.          newdata = substr(data, 1, serverp+1)||servername||,
  466.                    substr(data, serverp+8)
  467.          data = newdata
  468.       end
  469.       Call lineout tmpfit21, data
  470.    end
  471.    Call lineout tmpfit21
  472.    Call lineout fit21
  473.    '@RENAME 'fit21 ' DEFALT21.BAK'nulsufix
  474.    '@RENAME 'tmpfit21 ' DEFALT21.FIT'nulsufix
  475.    Call Delete_File rpldir'\FITS\DEFALT21.BAK'
  476.    return 0
  477.  
  478.  
  479.  
  480. /* This subroutine updates RPL.MAP to support OS/2 2.1 server records */
  481. Update_RPL_MAP:
  482.    Call Determine_Installed_OS2_Levels
  483.    rplmap = rpldir'\RPL.MAP'
  484.    rplmaptmp = rpldir'\RPLMAP.TMP'
  485.    Call Delete_File rplmaptmp
  486.    i = 1
  487.    os221flag = 0
  488.    srvrec.0 = 0
  489.    do until lines(rplmap) = 0
  490.       data = linein(rplmap)
  491.       ucdata = translate(data)
  492.       psrv = pos('YYYYYYYYYYYY', ucdata)
  493.       if psrv <> 0 & psrv < 3 Then Do
  494.          /* server record, check for OS/2 type */
  495.          pos2 = pos('OS2BB', ucdata)
  496.          if pos2 <> 0 Then Do
  497.             /* OS/2 1.3, determine if it should be enabled or disabled */
  498.             If os213 = 1 Then Do
  499.                /* should be enabled */
  500.                If substr(data, 1, 1) = ';' Then data = substr(data, 2)
  501.             end
  502.             else Do
  503.                /* should be disabled */
  504.                If substr(data, 1, 1) <> ';' Then data = ';'data
  505.             end
  506.          end
  507.          else Do
  508.             pos2 = pos('OS220', ucdata)
  509.             if pos2 <> 0 Then Do
  510.                /* OS/2 2.0 type, save it */
  511.                srvrec.0 = i
  512.                srvrec.i = data
  513.                i = i + 1
  514.                /* determine if it should be enabled or disabled */
  515.                If os220 = 1 Then Do
  516.                   /* should be enabled */
  517.                   If substr(data, 1, 1) = ';' Then data = substr(data, 2)
  518.                end
  519.                else Do
  520.                   /* should be disabled */
  521.                   If substr(data, 1, 1) <> ';' Then data = ';'data
  522.                end
  523.             end
  524.             else Do
  525.                /* check for OS2.20a record */
  526.                pos2 = pos('OS22A', ucdata)
  527.                If pos2 <> 0 Then Do
  528.                   /* os2.20a, determine if it should be enabled or disabled */
  529.                   If os220a = 1 Then Do
  530.                      /* should be enabled */
  531.                      If substr(data, 1, 1) = ';' Then data = substr(data, 2)
  532.                   end
  533.                   else Do
  534.                      /* should be disabled */
  535.                      If substr(data, 1, 1) <> ';' Then data = ';'data
  536.                   end
  537.                end
  538.                else Do
  539.                   /* check for existing 2.1 server record */
  540.                   pos2 = pos('OS221', ucdata)
  541.                   If pos2 <> 0 Then os221flag = 1
  542.                   else Do
  543.                      /* check for last server record */
  544.                      pos2 = pos('PCINIT.CNF', ucdata)
  545.                      If pos2 <> 0 Then Do
  546.                         /* end of server records, do we need to create new records? */
  547.                         If os221flag = 0 Then Do
  548.                            If srvrec.0 <> 0 Then Do
  549.                               /* need to create OS/2 2.1 records, use saved */
  550.                               /* OS220 records as a master */
  551.                               Do j = 1 to srvrec.0
  552.                                  /* locate OS/2 cnf entry in field 2 */
  553.                                  pos2 = pos('OS220', translate(srvrec.j))
  554.                                  newdata = substr(srvrec.j, 1, pos2+3) || '1'
  555.                                  startpoint = pos2+5
  556.  
  557.                                  /* locate OS type in field 7 */
  558.                                  pos2 = pos('~2.0~', srvrec.j, startpoint)
  559.                                  If pos2 <> 0 Then Do
  560.                                     /* LS 3.0 record format */
  561.                                     newdata = newdata ||,
  562.                                        substr(srvrec.j, startpoint, (pos2+3)-startpoint)
  563.                                     newdata = newdata || '1'
  564.                                     startpoint = pos2 + 4
  565.                                  end
  566.                                  else Do
  567.                                     pos2 = pos('~20~', srvrec.j, startpoint)
  568.                                     If pos2 <> 0 Then Do
  569.                                     /* LS 2.0 record format */
  570.                                        newdata = newdata ||,
  571.                                           substr(srvrec.j, startpoint, (pos2+3)-startpoint)
  572.                                        newdata = newdata || '1'
  573.                                        startpoint = pos2 + 3
  574.                                     end
  575.                                     else Do
  576.                                        /* type not recognized, doing nothing */
  577.                                        /* will cause existing description */
  578.                                        /* (field 7) to be used. */
  579.                                     end
  580.                                  end
  581.  
  582.                                  /* locate OS type in field 12 */
  583.                                  pos2 = pos('_20_', srvrec.j, startpoint)
  584.                                  newdata = newdata || substr(srvrec.j, startpoint, (pos2+2)-startpoint)
  585.                                  newdata = newdata || '1'
  586.                                  startpoint = pos2 + 3
  587.                                  newdata = newdata || substr(srvrec.j, startpoint)
  588.                                  if substr(newdata, 1, 1) = ';' Then Do
  589.                                     ucnewdata = translate(newdata)
  590.                                     pos2 = pos('OS221', ucnewdata)
  591.                                     adaptype = substr(ucnewdata, pos2+5, 3)
  592.                                     /* if not 3COM entry, enable record */
  593.                                     If adaptype <> '3EI' & adaptype <> '3EM' Then newdata = substr(newdata, 2)
  594.                                  end
  595.                                  Call lineout rplmaptmp, newdata
  596.                               end
  597.                            end
  598.                         end
  599.                      end
  600.                   end
  601.                end
  602.             end
  603.          end
  604.       end
  605.       else Do
  606.          pos2 = pos('1000FFFFFFFF', data)
  607.          if pos2 <> 0 Then Do
  608.             /* OS2 default workstation record, try to make sure fields 4 & 12 */
  609.             /* are valid */
  610.             field12 = word(data, 12)
  611.             pf12 = pos(field12, data)
  612.             os2type = substr(field12, 3, 2)
  613.             f12flag = 1
  614.             If os2type = '20' & os220 = 0 Then f12flag = 0
  615.             else If os2type = '2A' & os22a = 0 Then f12flag = 0
  616.                else If os2type = '21' & os221 = 0 Then fl12flag = 0
  617.                   else If substr(os2type, 1, 1) = 'O' & os213 = 0 Then fl12flag = 0
  618.             If f12flag = 0 Then Do
  619.                /* field 12 is invalid, therefore so is field 4, update */
  620.                /* them so they are valid */
  621.                If os220 = 1 Then os2type = '20'
  622.                else If os22a = 1 Then os2type = '2A'
  623.                     else If os221 = 1 Then os2type = '21'
  624.                          else os2type = '21'  /* default to 21 */
  625.                If os2type <> '' Then Do
  626.                   field4 = word(data, 4)
  627.                   pf4 = pos(field4, data)
  628.                   pf4 = pf4 + length(field4) - 3
  629.                   If os2type = '2A' Then newdata = substr(data, 1, pf4) || '20'
  630.                   else newdata = substr(data, 1, pf4) || os2type
  631.                   newdata = newdata || substr(data, pf4+3, pf12-pf4-1) || os2type
  632.                   data = newdata || substr(data, pf12+4)
  633.                end
  634.             end
  635.          end
  636.       end
  637.       Call lineout rplmaptmp, data
  638.    end
  639.    Call lineout rplmap
  640.    Call lineout rplmaptmp
  641.  
  642.    If os221flag = 0 Then Do
  643.       /* replace old RPL.MAP with new RPL.MAP */
  644.       rplmapxxx = 'RPLMAP.xxx'
  645.       Call Delete_File rpldir'\'rplmapxxx
  646.       '@rename 'rplmap  rplmapxxx nulsufix
  647.       '@rename 'rplmaptmp 'RPL.MAP'nulsufix
  648.       Call Delete_File rpldir'\'rplmapxxx
  649.    end
  650.    else Call Delete_File rpldir'\'rplmaptmp
  651.  
  652.    return
  653.  
  654.  
  655. /* This subroutine creates CNF file for OS/2 2.1 */
  656. Create_os221_cnf_files:
  657.    /* build list of possible source cnf filenames */
  658.    cnflist.0 = 5
  659.    cnflist.1 = 'os220tr'
  660.    cnflist.2 = 'os220et'
  661.    cnflist.3 = 'os220pc'
  662.    cnflist.4 = 'os2203ei'
  663.    cnflist.5 = 'os2203em'
  664.  
  665.    Do i = 1 to cnflist.0
  666.       srccnffile = rpldir'\'cnflist.i'.cnf'
  667.       trgcnffile = rpldir'\'substr(cnflist.i,1,4)'1'substr(cnflist.i,6)'.cnf'
  668.       If File_Exist(srccnffile) = 1 Then Do
  669.          /* source file exists, check target file */
  670.          If File_Exist(trgcnffile) = 0 Then Do
  671.             /* file does not exist, create it */
  672.             do until lines(srccnffile) = 0
  673.                data = linein(srccnffile)
  674.                ucdata = translate(data)
  675.                pos2 = pos('OS2.20\', ucdata)
  676.                if pos2 <> 0 Then Do
  677.                   /* update OS/2 directory reference */
  678.                   newdata = substr(data, 1, pos2+4) || '1' || substr(data, pos2+6)
  679.                   data = newdata
  680.                end
  681.                Call lineout trgcnffile, data
  682.             end
  683.             Call lineout srccnffile
  684.             Call lineout trgcnffile
  685.          end
  686.       end
  687.    end
  688.    return
  689.  
  690.  
  691.  
  692. /* Subroutine Update_Master_Configri_20 */
  693. /* This subroutine creates new master CONFIGRI.20 files that have the */
  694. /* DRIVER=x:\OS2\TESTCFG.SYS statement added to it */
  695. Update_Master_Configri_20:
  696.  
  697.    /* build list of directories in RPL\IBMCOM to process */
  698.    lanlist.0 = 6
  699.    lanlist.1 = 'TOKENRNG'
  700.    lanlist.2 = 'ETHERNET'
  701.    lanlist.3 = 'PCNETA'
  702.    lanlist.4 = 'PCNET'
  703.    lanlist.5 = 'ELNKII'
  704.    lanlist.6 = 'ELNKMC'
  705.  
  706.    Do i = 1 to lanlist.0
  707.       lantype = lanlist.i
  708.       configfilename = rpldir'\IBMCOM\'lantype'\CONFIGRI.20'
  709.       If File_Exist(configfilename) <> 0 Then Do
  710.          /* build fully qualified path name for master CONFIGRI.20 */
  711.          configname = rpldir'\IBMCOM\'lantype'\CONFIGRI.20'
  712.          tmpconfigname = rpldir'\IBMCOM\'lantype'\CONFIGRI.20T'
  713.          bakconfigname = rpldir'\IBMCOM\'lantype'\CONFIGRI.20B'
  714.  
  715.          /* Call SysFileDelete tmpconfigname */
  716.          Call Delete_File tmpconfigname
  717.          Call Delete_File bakconfigname
  718.  
  719.          bootdrv = 'Z'
  720.          /* copy records looking for TESTCFG.SYS statement */
  721.          flag = 0
  722.          do until lines(configname) = 0
  723.             data = linein(configname)
  724.             ucdata = translate(data)
  725.             dpos = pos('SET PATH=', ucdata)
  726.             if dpos <> 0 Then Do
  727.                /* get bootdrive id from SET PATH statement */
  728.                dpos = pos(':\OS2;', ucdata)
  729.                if dpos <> 0 Then bootdrv = substr(ucdata, dpos-1, 1)
  730.             end
  731.             dpos = pos('DEVICE=', ucdata)
  732.             If dpos <> 0 Then Do
  733.                If pos('\OS2\TESTCFG.SYS', ucdata, dpos+7) <> 0 Then Do
  734.                   /* DEVICE statement already present */
  735.                   If word(ucdata, 1) = 'REM' Then Do
  736.                      /* statement REMed out, un-REM it */
  737.                      newdata = substr(data, dpos)
  738.                      data = newdata
  739.                   end
  740.                   flag = 1
  741.                end
  742.             end
  743.             Call lineout tmpconfigname, data
  744.          end
  745.          If flag = 0 Then Do
  746.             /* add DEVICE statement to end of file */
  747.             Call lineout tmpconfigname, 'DEVICE='bootdrv':\OS2\TESTCFG.SYS'
  748.          end
  749.  
  750.          Call Lineout tmpconfigname   /* close file */
  751.          Call Lineout configname      /* close file */
  752.  
  753.          /* rename original CONFIGRI.20 */
  754.          '@rename 'configname' CONFIGRI.20B'
  755.          if rc = 0 Then Do
  756.             /* rename CONFIGRI.20T to be CONFIGRI.20 */
  757.             '@rename 'tmpconfigname' CONFIGRI.20'
  758.             if rc = 0 Then Do
  759.                /* delete orginal CONFIGRI.20 */
  760.                Call Delete_File bakconfigname
  761.             end
  762.             else Do
  763.                /* rename error, try to restore original */
  764.                '@rename 'bakconfigname' CONFIGRI.20'
  765.             end
  766.          end
  767.       end
  768.    end
  769.    return 0
  770.  
  771.  
  772.  
  773. Determine_Boot_Drive:
  774.    /* find the boot driver id */
  775.    os2path = value('PATH',,'OS2ENVIRONMENT')
  776.  
  777.    os2p = pos(':\OS2', translate(os2path))
  778.    if os2p = 0 Then Do
  779.      msgdata = errprefix || message.5
  780.      Call Display_Log_Msg msgdata, ''
  781.      return 4
  782.    end
  783.  
  784.    bootdrv = substr(os2path, os2p-1, 1)
  785.    return 0
  786.  
  787.  
  788.  
  789. Determine_RIPL_Directory:
  790.    /* find out where IBMLAN is installed */
  791.    os2path = value('PATH',,'OS2ENVIRONMENT')
  792.  
  793.    ibmlanp = pos(':\IBMLAN', translate(os2path))
  794.    if ibmlanp = 0 Then Do
  795.      msgdata = errprefix || message.6
  796.      Call Display_Log_Msg msgdata, ''
  797.      return 4
  798.    end
  799.  
  800.    landrv = substr(os2path, ibmlanp-1, 1)
  801.    lanpath = landrv':\IBMLAN'
  802.  
  803.    fname = lanpath'\IBMLAN.INI'
  804.  
  805.    /* read IBMLAN.INI looking for the RPLDIR entry */
  806.    do until lines(fname) = 0
  807.       data = translate(linein(fname))
  808.       rpldirp = pos('RPLDIR', data)
  809.       if rpldirp <> 0 then do
  810.          rpldirp = pos('=', data)
  811.          rpldir = strip(substr(data, rpldirp+1))
  812.          Leave
  813.       end
  814.    end
  815.    Call stream fname,C,'close'
  816.  
  817.    if rpldir = '' then do
  818.       msgdata = errprefix || message.13
  819.       Call Display_Log_Msg msgdata, ''
  820.       return 4
  821.    end
  822.    return 0
  823.  
  824.  
  825.  
  826. /* Process command line parameters */
  827. Process_Input_Parameters:
  828.    Arg  parm.1, parm.2, parm.3
  829.    Do i = 1 to 3
  830.       If parm.i = '' Then Leave
  831.       parmtype = substr(parm.i,1,2)
  832.       select
  833.          when parmtype = '?' Then Call Syntax_Help
  834.  
  835.          when parmtype = '/H' Then Call Syntax_Help
  836.  
  837.          when parmtype = '/L' Then Do
  838.             /* Logfile parameter */
  839.             if substr(parm.i, 3, 1) = ':' Then Logfile = substr(parm.i, 4)
  840.             else Logfile = substr(parm.i, 3)
  841.          end
  842.  
  843.          when parmtype = '/S' Then Do
  844.             /* Sourcepath parameter */
  845.             if substr(parm.i, 3, 1) = ':' Then SourcePath = substr(parm.i, 4)
  846.             else SourcePath = substr(parm.i, 3)
  847.             If substr(SourcePath, length(SourcePath), 1) <> '\' Then Do
  848.                /* insure path ends in a \ */
  849.                SourcePath = SourcePath || '\'
  850.             end
  851.          end
  852.  
  853.          otherwise Do
  854.             msgdata = errprefix || message.4
  855.             Call Display_Log_Msg msgdata, parm.i
  856.             return 4
  857.          end
  858.       end
  859.    end
  860.    return 0
  861.  
  862.  
  863. Syntax_Help:
  864.    do i = 30 to 33
  865.       Call Display_Log_Msg message.i, ''
  866.    end
  867.    exit
  868.  
  869.  
  870.  
  871. Initialize_NLS_Messages:
  872. /***********************************************************************/
  873. /*                            NLS messages                             */
  874. /*                                                                     */
  875. /* The following message strings should be translated for NLS support. */
  876. /*                                                                     */
  877. /* Note: The %1, %2, etc. strings represent dynamic data fields that   */
  878. /*       are filled in when the message is displayed.  Do not          */
  879. /*       translate the %1, %2, etc. fields.                            */
  880. /*       The 'CRLF,' sequence that ends some lines represents          */
  881. /*       formatting control (new line) and should not be translated.   */
  882. /*       However, after translation, each message may need to be       */
  883. /*       manually reformatted to prevent excessive length message      */
  884. /*       lines. The message display code does not automatically        */
  885. /*       reformat long message lines.                                  */
  886. /***********************************************************************/
  887. arg message_type
  888.    /* error message prefix */
  889.    errprefix = 'ERROR: '
  890.  
  891.    /* start of error messages */
  892.    message.1 = 'Missing keyword in '
  893.    message.2 = 'HISTORY LOG: '
  894.    message.3 = 'Unable to open the Logfile '
  895.    message.4 = 'The option %1 is not a valid option.'
  896.    message.5 = 'Unable to determine the boot driver id.'
  897.    message.6 = 'Unable to determine where LAN Server is installed.'
  898.    message.7 = 'Unable to determine the server name.'
  899.    message.8 = 'DEFALT21.FIT was not updated.'
  900.    message.9 = 'Error copying %1 to %2.'
  901.    message.10 = 'PKUNZIP2 Error while installing %1 to %2.'
  902.    message.11 = 'The level of LAN Server installed is %1.  This level of' CRLF,
  903.                 '      LAN Server can not be updated to support OS/2 2.1.'
  904.    message.12 = 'The level of LAN Server installed is %1.  This level of' CRLF,
  905.                 '      LAN Server does not need to be upgraded.'
  906.    message.13 = 'The RPLDIR parameter was not found in IBMLAN.INI.'
  907.  
  908.    /* start of informational messages */
  909.    message.15 = 'RPL.MAP was updated to support OS/2 2.1.'
  910.    message.16 = 'OS221*.CNF files were created.'
  911.    message.17 = 'DEFALT21.FIT was updated.'
  912.    message.18 = 'Copying %1 to %2.'
  913.    message.19 = 'Installing %1 to %2.'
  914.    message.20 = 'Creating new Remote IPL subdirectories.'
  915.    message.21 = 'Master CONFIGRI.20 files were updated.'
  916.  
  917.    /* start of syntax help messages */
  918.    message.30 = 'RPLMIG21.CMD  [ ? | /h | /H] [/S:Sourcepath] [/L:Logfile]'CRLF
  919.    message.31 = '    where ? or /h or /H is a request for this help panel.  If specified, it' CRLF,
  920.                 '           must be first parameter.'CRLF
  921.    message.32 = '          /S:Sourcepath is the fully qualified path to the root directory' CRLF,
  922.                 '            which contains the files to be installed by RPLMIG21.  The' CRLF,
  923.                 '            default value is A:\.' CRLF
  924.    message.33 = '          /L:Logfile is the fully qualified name of a file to which all' CRLF,
  925.                 '            messages and errors are to be logged.  If Logfile is specified,' CRLF,
  926.                 '            no messages or errors will be displayed on the screen.'
  927.  
  928.  
  929.  
  930.    return
  931.